package billrestauration.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.commons.collections.map.HashedMap;

public class Util {
public static String currentDir(){
	Process p;
	try {
		p = Runtime.getRuntime().exec("pwd");
		BufferedReader r=new BufferedReader(new InputStreamReader(p.getInputStream()));
		String line;
		while(null!=(line=r.readLine()))
		{return line;
			
		}
	} catch (IOException e) {
		// TODO Auto-generated catch block
		return null;
	}
	return null;
}
public static List<Object> exec(String commande){
	Process p;
	List<Object> res=new ArrayList<Object>();
	try {
		p = Runtime.getRuntime().exec(commande);
		BufferedReader r=new BufferedReader(new InputStreamReader(p.getInputStream()));
		String line;
		while(null!=(line=r.readLine()))
		{ res.add(line);
			
		}
		return res;
	} catch (IOException e) {
		// TODO Auto-generated catch block
		return null;
	}
	 
}
public static HashMap<String,List<Object>>  exec(String[] commande){
	HashMap<String,List<Object>> res=new HashMap<String,List<Object>> ();
	for (String string : commande) {
		res.put(string, Util.exec(string));
	}
	return res;
	 
}
}
